%% FFT Video

%% Setup
tic
clear all;
close all;



Fs=100;	% Sampling Freq
Ts=1/Fs;	% Sample time
L=600;		% Number of samples
t=(0:L-1)*Ts; %Time Vector

figure(1);
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
grid on
for i=1:1000
	% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
	y = sin(2*pi*(45+i*0.8)*t) + cos(2*pi*(i*0.5)*t) + randn(size(t));% Sinusoids plus noise
	%% Compute FFT
	NFFT = 2^nextpow2(L); % Next power of 2 from length of y
	Y = fft(y,NFFT)/L;
	f = Fs*linspace(0,.5,NFFT/2+1);
	amp=2*abs(Y(1:NFFT/2+1));
	plot(f,amp);
	axis([0 50 0 2]);
	pause(.2);
end